**********************************************************************************************************
**********************************************************************************************************
**********************************************************************************************************
* Do-file for the paper
* Does Goal Revision Undermine Self-Regulation Through Goals? An Experiment
* by Jonas Pilgaard Kaiser, Alexander K. Koch, and Julia Nafziger
**********************************************************************************************************
**********************************************************************************************************
**********************************************************************************************************
/*
In the following, we provide the Stata codes that replicate the results from the paper 
"Does Goal Revision Undermine Self-Regulation Through Goals? An Experiment". 
The do-file follows the same structure as the paper.
*/
clear all

*Make sure to have the following stata package installed
//ssc install stripplot
//package st0035 from http://www.stata-journal.com/software/sj3-2

*Set the following path: 
global path "SET YOUR PATH HERE" // e.g. global path "C:\Documents\EXE\"

*Input contains the data set, all outputs will be stored in the output folder.
global input "$path\Input"
global output "$path\Output"
global temp "$path\Temp"

cd "$input"
use ReplicationData.dta


********************************************************************************
********************************************************************************
***                                2.2 SAMPLE                                ***
********************************************************************************
********************************************************************************
***In text: Descriptive data on the sample composition
//Note: Average payments and total number of participants invited to the study are taken from separate Excel sheets

*Total number of participants who completed date 0
count if ID!=.

*Total number of participants for date 1
count if d1completed==1

*Total number of participants for date 2
count if d2completed==1

*Number and share of subjects within bachelor, master, and phd/other
count if d1completed==1
scalar all=r(N)

count if degree==1 & d1completed==1
scalar bachelor=r(N)
di bachelor/all

count if degree==2 & d1completed==1
scalar master=r(N)
di master/all

count if (degree==3 | degree==4) & d1completed==1
scalar phd_other=r(N)
di phd_other/all

*Number and share of subjects who are not students
tab faculty if d1completed==1

*Number and share of subjects who study economics/business
count if econbusi==1 & d1completed==1
scalar econ_busi=r(N)
di econ_busi/all

********************************************************************************
********************************************************************************
***                           3.2 MAIN HYPOTHESES                            ***
********************************************************************************
********************************************************************************
***Table 2: Calculate effect sizes for each hypothesis
*Hypothesis 1.1: Compare goals set in Early and Late
gen treatcomp = (treatment==1) 
label define treatcomp_label 1 "Late" 0 "Early"
label values treatcomp treatcomp_label
esize twosample displaygoal if d1completed==1 & (treatment==1 | treatment==2), by(treatcomp) 
drop treatcomp 
label drop treatcomp_label

*Hypothesis 1.2: Compare goal 0 and goal 1 in Revise treatments
esize unpaired goal0==goal1 if (treatment==3 | treatment==4)

*Hypothesis 2.1: Compare effort in Early and Late
gen treatcomp = (treatment==1) 
label define treatcomp_label 1 "Late" 0 "Early"
label values treatcomp treatcomp_label
esize twosample effort if d1completed==1 & (treatment==1 | treatment==2), by(treatcomp) 
drop treatcomp 
label drop treatcomp_label

*Hypothesis 2.2: Compare effort in Revise1 and Late
gen treatcomp = (treatment==1) 
label define treatcomp_label 1 "Late" 0 "Revise1"
label values treatcomp treatcomp_label
esize twosample effort if d1completed==1 & (treatment==1 |treatment==4), by(treatcomp) 
drop treatcomp 
label drop treatcomp_label

*Hypothesis 3.1: Compare effort in Early and Revise0
gen treatcomp = (treatment==3) 
label define treatcomp_label 0 "Early" 1 "Revise0"
label values treatcomp treatcomp_label
esize twosample effort if d1completed==1 & (treatment==2 | treatment==3), by(treatcomp) 
drop treatcomp 
label drop treatcomp_label

*Hypothesis 3.2: Compare effort in Revise0 and Revise1
gen treatcomp = (treatment==4) 
label define treatcomp_label 0 "Revise0" 1 "Revise1"
label values treatcomp treatcomp_label
esize twosample effort if d1completed==1 & (treatment==3 | treatment==4), by(treatcomp) 
drop treatcomp 
label drop treatcomp_label

********************************************************************************
********************************************************************************
***                   4.1 MAIN VARIABLES AND ANALYSIS PLAN                   ***
********************************************************************************
********************************************************************************
***Table 3: Generate table with descriptive statistics
*Prepare matrix
matrix Table3 = J(5,8,.)
matrix colnames Table3 = "N" "Average Goal 0" "Average Goal 1" "Average Effort" "Goal0 Achieved" "Goal1 Achieved" "Productivity 1" "Productivity 2"
matrix rownames Table3 = "Early" "Late" "Revise0" "Revise1" "Total"

*Loop over variables included in the descriptive statistics, filling out the data for each treatment, and exporting as Tex
quietly{
local countcolumn=1
foreach i in goal0 goal1 effort achieve_bin_0 achieve_bin_1 d0productivity1 d1productivity1 {
	forvalues j = 1(1)5 {
		if `j'==1 {
			summarize `i' if treatment==1
			matrix Table3[2,1] = r(N)
			matrix Table3[2,`countcolumn'+1] = r(mean)
		}

		if `j'==2 {
			summarize `i' if treatment==2
			matrix Table3[1,1] = r(N)
			matrix Table3[1,`countcolumn'+1] = r(mean)
		}

		if `j'==3 {
			summarize `i' if treatment==3
			matrix Table3[3,1] = r(N)
			matrix Table3[3,`countcolumn'+1] = r(mean)
		}

		if `j'==4 {
			summarize `i' if treatment==4
			matrix Table3[4,1] = r(N)
			matrix Table3[4,`countcolumn'+1] = r(mean)
		}		

		if `j'==5 {
			summarize `i' if d1completed==1
			matrix Table3[5,1] = r(N)
			matrix Table3[5,`countcolumn'+1] = r(mean)
		}
	}
local countcolumn=`countcolumn'+1
}
}
*Exporting matrix as TeX, specifying number of decimals
esttab matrix(Table3,fmt(0 2 2 2 2 2 2 2)) using "$output/Table3.tex", tex  replace

********************************************************************************
********************************************************************************
***                          4.2 GOAL SETTING (H1)                           ***
********************************************************************************
********************************************************************************
***In text
*See Table 3 for the difference in goals and the increases in productivity from date 0 to date 1

*Variance explained by increase in productivity
quietly reg displaygoal ib(2).treatment if treatment==1 | treatment==2, robust
glo r2_1=e(r2)
quietly reg displaygoal ib(2).treatment base_productivity if treatment==1 | treatment==2, robust
glo r2_2=e(r2)
di $r2_2 - $r2_1

**Descriptive statistics about goal revision
*Share of subjects who revise their goals
sum goalrevision_bin
scalar all=r(N)

*Average goal revision conditional on revision
sum goalrevision_cont if goalrevision_bin==1
sum goalrevision_cont if goalrevision_bin==1 & goalrevision_cont>-700 

*Average goal revision conditional on downward revision
sum goalrevision_cont goal1 if goalrevision_bin==1 & goalrevision_cont<0
scalar down=r(N)
di down/all

*Average goal1 conditional on no goal revision
sum goalrevision_bin
sum goal1 if goalrevision_bin==0

*Average goal revision conditional on upward revision
sum goalrevision_cont goal1 if goalrevision_bin==1 & goalrevision_cont>0
scalar up=r(N)
di up/all

***Table 4: Regressions to test Hypotheses 1.1 and 1.2
*H1.1: No controls
eststo goal1no: reg displaygoal ib(2).treatment if treatment==1 | treatment==2, robust
*H1.1: Control for baseline productivity
eststo goal1prod: reg displaygoal ib(2).treatment base_productivity if treatment==1 | treatment==2, robust
*H1.1: All controls
eststo goal1all: reg displaygoal ib(2).treatment base_productivity crt slidermoved response_time selfcomp risk enjoypre time_constrained if (treatment==1 | treatment==2) & schedule_error==0, robust
*H1.2: No controls
eststo goal2no: reg goalrevision_cont, robust
*H1.2: Control for baseline productivity
eststo goal2prod: reg goalrevision_cont productivity_change, robust
*H1.2: All controls
eststo goal2all: reg goalrevision_cont productivity_change crt d0slidermoved d1slidermoved d0response_time d1response_time selfcomp risk enjoypre uncertainty moretime lesstime, robust

*Combine regressions in a table and export as TeX
esttab goal* using "$output/Table4.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Goal Setting") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Figure 4: Goals set by subjects
*Generate goals to be plotted and label according to treatment/goal
gen plotgoal1=goal0 if treatment==2
gen plotgoal2=goal1 if treatment==1
gen plotgoal3=goal0 if treatment>=3
gen plotgoal4=goal1 if treatment>=3

label variable plotgoal1 "Early"
label variable plotgoal2 "Late"
label variable plotgoal3 "Goal 0"
label variable plotgoal3 "Goal 1"

*Produce plot
stripplot plotgoal1 plotgoal2 plotgoal3 plotgoal4, box(bfcolor(gray) blcolor(black) barw(0.2)) yscale(r(0,1000)) ylabel(0(200)1000) ytitle("Goal") ///
xlabel(1 "Early" 2 "Late" 3 "Goal 0" 4 "Goal 1") vertical iqr jitter(2.5) mcolor(navy) msize(tiny) graphregion(fcolor(white)) ///
text(-130 1.5 "Between-subject comparison")  text(-130 3.5 "Within-subject comparison") ///
 text(-175 1.5 "Early vs Late")  text(-175 3.5 "Revise0 & Revise1") 
graph export "$output/Figure4.png", replace

***Figure 5: Goal revision in Revise0 and Revise1
*a: Create histogram to explain goal revision
hist goalrevision_bin if treatment>=3, discrete xscale(r(1 2)) yscale(r(0 0.7)) ylab(0(0.1)0.7,labsize(medlarge)) ///
xlab(1 "Yes" 0 "No",labsize(medlarge)) addlabel  xtitle("Goal revision", size(medlarge)) ytitle("Fraction", size(medlarge)) ///
addlabopts(yvarformat(%4.2f) mlabsize(medlarge)) frac lcolor(black) fcolor(gs12) scheme(lean1) saving("$temp/goalrevisionextensive.gph",replace)
graph export "$output/Figure5a.png", replace

*b: Create stripplot (boxplot that shows data points) for goal revision conditional on revision
stripplot goalrevision_cont if goalrevision_bin==1 & treatment>=3, ytitle("goal 1 - goal 0", size(medlarge)) xlabel("") ///
box(bfcolor(gray) blcolor(black) barw(0.06)) yscale(r(-750,300)) ylabel(-750(150)300,labsize(medlarge)) xscale(r(1,1.5))  vertical iqr jitter(2.5) mcolor(navy) msize(vsmall) graphregion(fcolor(white)) saving("$temp/goalrevisionintensive.gph",replace)
graph export "$output/Figure5b.png", replace

********************************************************************************
********************************************************************************
***          4.3.1 ARE GOALS EFFECTIVE SELF-REGULATION TOOLS? (H2)           ***
********************************************************************************
********************************************************************************
***In text
*See Table 3 for the difference in effort

*Mann-Whitney U Test comparing effort between subjects in Early and Late
ranksum effort if d1completed==1 & treatment<3, by(d0late)

*Mann-Whitney U Test comparing effort between subjects in Revise1 and Late
ranksum effort if d1completed==1 & (treatment==1 |treatment==4), by(d0late)

*Summary statistics on subjects' effort
sum effort if d1completed==1 & treatment==1
sum effort if d1completed==1 & treatment==2

***Updated power calculations
/*The following code reproduces the power calculations that show how one would need at least 900 subjects to obtain a power of 0.8 to detect a significant difference between subjects in Late and Early. This is commented out here by default as the simulations change the data set.
drop if treatment>2

*Replicate existing sample 1000 times and make a variable to identify the first 164 subjects, who make out the original sample. 
//This is not exactly drawing observations with replacement, but the standard commands in Stata have problems drawing with replacement more observations than are in the original data set.
expand 1000
gen identifier=_n

///Analysis from paper, Early vs. Late:
*No controls:
reg effort ib(2).treatment if treatment<=2 & identifier<=164, robust

*Control for d1productivity:
reg effort ib(2).treatment d1productivity1 if treatment<=2 & identifier<=164, robust //Using Early as baseline

///Power for new comparison, using old sample as population:
mat estimates = J(800,4,.)
mat pow = J(60,5,.)

*Loop over different sample sizes
local countrow = 1
quietly forvalues j=200(100)1200 {
capture drop reg_pval*
capture drop effectsize*
capture drop significant_reg*
capture drop temp*
*Obtain power and effect size estimates
quietly forvalues i=1(1)800 {
set seed `i'
preserve
sample `j', count
reg effort ib(2).treatment if treatment<=2, robust
matrix estimates[`i',1]=r(table)[4,1]
matrix estimates[`i',2]=r(table)[1,1]

reg effort ib(2).treatment d1productivity1 if treatment<=2, robust
matrix estimates[`i',3]=r(table)[4,1]
matrix estimates[`i',4]=r(table)[1,1]
restore
}

matrix pow[`countrow',1]=`j'

*Convert from values stored in matrix to variables
svmat estimates, names(temp)
rename temp1 reg_pval
rename temp2 effectsize
rename temp3 reg_pvalprod
rename temp4 effectsizeprod

*Obtain and save estimates of power and effect sizes
gen significant_reg = 0 if reg_pval!=.
replace significant_reg = 1 if reg_pval<0.05
ci means significant_reg
matrix pow[`countrow',2]=r(mean)

ci means effectsize
matrix pow[`countrow',3]=r(mean)

*Obtain and save estimates of power and effect sizes, controlling for productivity
gen significant_regprod = 0 if reg_pvalprod!=.
replace significant_regprod = 1 if reg_pvalprod<0.05
ci means significant_regprod
matrix pow[`countrow',4]=r(mean)

ci means effectsizeprod
matrix pow[`countrow',5]=r(mean)
local countrow = `countrow'+1

noisily display `j'

}

*Convert power matrix to variables
svmat pow, names(temp)

*Rename variables
rename temp1 SampleSize
rename temp2 Power
rename temp3 AvgEffectSize
rename temp4 PowerProd
rename temp5 AvgEffectSizeProd

//Browse data to see the table that compares sample sizes and power.
*/

***Table 5: Regressions to test Hypotheses 2.1 and 2.2
*H2.1: No controls
eststo effort21no: reg effort ib(2).treatment if treatment==1 | treatment==2, robust
*H2.1: Control for baseline productivity
eststo effort21prod: reg effort ib(2).treatment d1productivity1 if treatment==1 | treatment==2, robust
*H2.1: All controls
eststo effort21all: reg effort ib(2).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==2) & schedule_error==0, robust
*H2.1: No controls, add goal
eststo effort21goalno: reg effort ib(2).treatment displaygoal if treatment==1 | treatment==2, robust
*H2.1: Control for baseline productivity, add goal
eststo effort21goalprod: reg effort ib(2).treatment d1productivity1 displaygoal if treatment==1 | treatment==2, robust
*H2.1: All controls, add goal
eststo effort21goalall: reg effort ib(2).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==1 | treatment==2) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effort21* using "$output/Table5-1.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Effort") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

//Late vs. Revise1
*H2.2: No controls
eststo effort22no: reg effort ib(1).treatment if treatment==1 | treatment==4, robust
*H2.2: Control for baseline productivity
eststo effort22prod: reg effort ib(1).treatment d1productivity1 if treatment==1 | treatment==4, robust
*H2.2: All controls
eststo effort22all: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==4) & schedule_error==0, robust
*H2.2: No controls, add goal
eststo effort22goalno: reg effort ib(1).treatment displaygoal if treatment==1 | treatment==4, robust
*H2.2: Control for baseline productivity, add goal
eststo effort22goalprod: reg effort ib(1).treatment d1productivity1 displaygoal if treatment==1 | treatment==4, robust
*H2.2: All controls, add goal
eststo effort22goalall: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==1 | treatment==4) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effort22* using "$output/Table5-2.tex", replace nomtitles drop(1.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Effort") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table 6: Regressions to test Hypotheses 3.1 and 3.2
//Early vs. Revise0
*H3.1: No controls
eststo effort31no: reg effort ib(2).treatment if treatment==3 | treatment==2, robust
*H3.1: Control for baseline productivity
eststo effort31prod: reg effort ib(2).treatment d1productivity1 if treatment==3 | treatment==2, robust
*H3.1: All controls
eststo effort31all: reg effort ib(2).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==3 | treatment==2) & schedule_error==0, robust
*H3.1: No controls, add goal
eststo effort31goalno: reg effort ib(2).treatment displaygoal if treatment==3 | treatment==2, robust
*H3.1: Control for baseline productivity, add goal
eststo effort31goalprod: reg effort ib(2).treatment d1productivity1 displaygoal if treatment==3 | treatment==2, robust
*H3.1: All controls, add goal
eststo effort31goalall: reg effort ib(2).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==3 | treatment==2) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effort31* using "$output/Table6-1.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Effort") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

//Revise0 vs. Revise1
*H3.2: No controls
eststo effort32no: reg effort ib(3).treatment if treatment==3 | treatment==4, robust
*H3.2: Control for baseline productivity
eststo effort32prod: reg effort ib(3).treatment d1productivity1 if treatment==3 | treatment==4, robust
*H3.2: All controls
eststo effort32all: reg effort ib(3).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==3 | treatment==4) & schedule_error==0, robust
*H3.2: No controls, add goal
eststo effort32goalno: reg effort ib(3).treatment displaygoal if treatment==3 | treatment==4, robust
*H3.2: Control for baseline productivity, add goal
eststo effort32goalprod: reg effort ib(3).treatment d1productivity1 displaygoal if treatment==3 | treatment==4, robust
*H3.2: All controls, add goal
eststo effort32goalall: reg effort ib(3).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==3 | treatment==4) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effort32* using "$output/Table6-2.tex", replace nomtitles drop(3.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Effort") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Figure 6: Effort exerted by subjects by treatment
*Generate variable to sort treatments according to H2 and H3
gen plottreat1=treatment
recode plottreat1 (2=1) (3=2) (4=3) (1=4)
label variable plottreat1 "Treatment"
label define plottreat1_label 1 "Early" 2 "Revise0" 3 "Revise1" 4 "Late"
label values plottreat1 plottreat1_label

*Create stripplot (boxplots that shows data points) for effort
stripplot effort, over(plottreat1) box(bfcolor(gray) blcolor(black) barw(0.2)) vertical iqr jitter(2.5) mcolor(navy) msize(tiny) graphregion(fcolor(white))
graph export "$output/Figure6.png", replace

********************************************************************************
********************************************************************************
***            4.3.2 CAN FRAMING MAKE GOALS MORE EFFECTIVE? (H3)             ***
********************************************************************************
********************************************************************************
***In text
**Compare coefficients for goal 0 and goal 1 across regressions
*Revise 0, only control for goal
eststo effortR0g0: reg effort goal0 if treatment==3
eststo effortR0g1: reg effort goal1 if treatment==3
suest effortR0g0 effortR0g1
test [effortR0g0_mean]goal0=[effortR0g1_mean]goal1

*Revise 0, control for goal and productivity
eststo effortR0g0prod: reg effort goal0 d1productivity1 if treatment==3
eststo effortR0g1prod: reg effort goal1 d1productivity1 if treatment==3
suest effortR0g0prod effortR0g1prod
test [effortR0g0prod_mean]goal0=[effortR0g1prod_mean]goal1

*Revise 0, control for goal and all other controls
eststo effortR0g0all: reg effort goal0 d1productivity1 crt selfcomp risk enjoypre d1time_constrained if treatment==3
eststo effortR0g1all: reg effort goal1 d1productivity1 crt selfcomp risk enjoypre d1time_constrained if treatment==3
suest effortR0g0all effortR0g1all
test [effortR0g0all_mean]goal0=[effortR0g1all_mean]goal1

*Revise 1, only control for goal
eststo effortR1g0: reg effort goal0 if treatment==4
eststo effortR1g1: reg effort goal1 if treatment==4
suest effortR1g1 effortR1g0
test [effortR1g1_mean]goal1=[effortR1g0_mean]goal0

*Revise 1, control for goal and productivity
eststo effortR1g0prod: reg effort goal0 d1productivity1 if treatment==4
eststo effortR1g1prod: reg effort goal1 d1productivity1 if treatment==4
suest effortR1g1prod effortR1g0prod
test [effortR1g1prod_mean]goal1=[effortR1g0prod_mean]goal0

*Revise 1, control for goal and all other controls
eststo effortR1g0all: reg effort goal0 d1productivity1 crt selfcomp risk enjoypre d1time_constrained if treatment==4
eststo effortR1g1all: reg effort goal1 d1productivity1 crt selfcomp risk enjoypre d1time_constrained if treatment==4
suest effortR1g1all effortR1g0all
test [effortR1g1all_mean]goal1=[effortR1g0all_mean]goal0

*Compare regression coefficient for goal 1 between Revise0 and Revise1
suest effortR0g1all effortR1g1all
test [effortR0g1all_mean]goal1=[effortR1g1all_mean]goal1

**Examine possible private goal revision in Early
*Share of subjects in Early who update their goal
tab goal1inmind

*Generate variables for private goal revision (continuous) and goal achievement for updated goal (continuous)
gen goalrevision_private=altgoal1-goal0 if treatment==2
gen achieve_contalt=effort-altgoal1 if treatment==2  

*Descriptive statistics on the extent of goal revision and goal achievement
sum goalrevision_private achieve_cont0 achieve_contalt if treatment==2 &  goal1inmind==1 & altgoal1<.

*Test if subjects who do not update their goal achieve their goal on average 
ttest achieve_cont0==0 if treatment==2 & goal1inmind==0

********************************************************************************
********************************************************************************
***                              4.4 ROBUSTNESS                              ***
********************************************************************************
********************************************************************************
//See alternative regressions below in the code related to the Online Supplement
***In text
*Count number of subjects with goal/effort larger than 900
count if ((goal0>=900 & goal0!=.) | (goal1>=900 & goal1!=.)) & d1completed==1
count if effort>=900 & d1completed==1

*Correlations between average mistakes/time spent pr. table and effort
//Note that this correlation excludes the two subjects who provide zero effort
corr time_mean mistakes_mean effort

***Table 7: Corrections for FDR and FWER
*Prepare matrix for output
matrix Table7 = J(6,3,.)
matrix colnames Table7 = "Unadjusted p-value" "FWER-adjusted" "FDR-adjusted"
matrix rownames Table7 = "H1.1: g_E>g_L" "H1.2: g0_R>g1_R" "H2.1: e_E>e_L" "H2.2: e_R1>e_L" "H3.1: e_E>e_R0" "H3.2: e_R0>e_R1"

*Store p-values from the main test
reg displaygoal ib(2).treatment base_productivity if treatment==1 | treatment==2, robust
scalar p1=r(table)[4,1]

reg goalrevision_cont productivity_change, robust
scalar p2=r(table)[4,2]

reg effort ib(2).treatment d1productivity1, robust
scalar p3=r(table)[4,1]
scalar p5=r(table)[4,3]

test _b[1.treatment]=_b[4.treatment]
scalar p4=r(p)
test _b[3.treatment]=_b[4.treatment]
scalar p6=r(p)

*Make list of the above p-values
gen pvalues=.
forvalues i = 1(1)6 {
	replace pvalues=p`i' in `i'
	}

*Create rank variable for the p-values
quietly multproc, puncor(0.05) method(simes) pvalue(pvalues) rank(pvrank)

*Calculate Holm-Šidák-adjusted p-values (adj. p = 1-(1-p)^(7-rank))
sort pvrank
gen hspvalues=.
replace hspvalues=1-(1-pvalues)^(7-pvrank)
replace hspvalues=hspvalues[_n-1] if hspvalues[_n-1]>hspvalues in 2/l

*Change order of p-values back to original to insert automatically in table below
sort ID earningssched 

*Calculate Benjamini-Hochberg-adjusted p-values (adj. p = p * (#tests)/rank)
gen bhpvalues=.
replace bhpvalues=pvalues*(6/pvrank)

*Insert (un)adjusted p-values in Table 6
forvalues i = 1(1)6 {
	matrix Table7[`i',1]=pvalues[`i']
	matrix Table7[`i',2]=hspvalues[`i']
	matrix Table7[`i',3]=bhpvalues[`i']
	}

*Export matrix as TeX
esttab matrix(Table7,fmt(4 4 4)) using "$output/Table7.tex" , tex  replace

********************************************************************************
********************************************************************************
*** 6.1 WHY DO GOALS WORK DESPITE GOAL REVISION? THE ROLE OF THE EARLY GOAL***
********************************************************************************
********************************************************************************
***In text
*Compare goal 1 in Late vs. Revise0/Revise1, descriptive statistics and regression
sum goal1 if treatment==3 | treatment==4
sum goal1 if treatment==1

reg goal1 d0late d1productivity1 crt selfcomp risk enjoypre d1time_constrained if schedule_error==0 & treatment!=2, robust 

*Revise0/Revise1: Shortfall of effort relative to goal 0 and goal 1
reg achieve_cont1 if treatment==3 | treatment==4, robust

*Late: Shortfall of effort relative to goal 1
reg achieve_cont1 if treatment==1, robust

********************************************************************************
********************************************************************************
***                S.2 FUNCTIONAL FORM FOR THE EFFECTIVE GOAL                ***
********************************************************************************
********************************************************************************
//See the code below for Tables S.15 and S.16.


********************************************************************************
********************************************************************************
***                            S.4 POWER ANALYSIS                            ***
********************************************************************************
********************************************************************************
***In text
**Previous evidence. 
//Note that this part uses data sets from other papers, and the code is therefore commented out below. Also, note that the code below was run on Stata Version 16 and may not work with other versions of Stata.
/*
*See Koch and Nafziger (2020) for the reported effect size therein

*Abeler et al. (2011): Use data set AER-2008-1240_R1_AbelerFalkGoetteHuffman2009_data_file (Link: doi.org/10.1257/aer.101.2.470)
*Provide summary statistics and estimate effect size based on their data set
drop if treat_hi==0 & treat_lo==0

bysort treat_hi: sum ws

esize twosample ws, by(treat_lo)

*Augenblick and Rabin (2019): Use the data set "decisions_data_w_ind" (Link: doi.org/10.1093/restud/rdy019)
*Format data as in Augenblick and Rabin's "04stat_and_graphs"
cap drop d_w_p p_non_mono p_opportunities

egen d_w_p=group(decisiondate workdate wid type)
bys d_w_p (wage): gen t_non_mono=(jobschosen<jobschosen[_n-1])  
bys d_w_p (wage): replace t_non_mono=. if _n==1
bys wid: egen p_non_mono=total(t_non_mono) 
gen p_more_than_5=(p_non_mono>5)

*Restrict analysis to their main sample
/*
Note that data_sample1 is the main decision sample, and wid_sample2 specifies 
that the main sample for people without ML estimation issues is used. 
This sample is used here to reflect the sample used in creating Figure 3 in the paper.
*/
drop if (${wid_sample2})==0 | ($data_sample1)==0

*Compare only 0 and 4-7 days (cf. Figure 3 in Augenblick and Rabin, 2019)
drop if distance<4 & distance>0 
drop if distance>7

*Generate averages on individual level at the two dates; one obs pr. individual, rest is missing
gen avgnow=.
gen avglater=.

sum wid //Note that we have 100 individuals in the total sample

forvalues i = 1/100 {
capture{ //Using capture because loop otherwise terminates at missing observations (wid=87 is missing)
quietly mean(jobschosen) if distance==0 & wid==`i'
scalar an`i'=e(b)[1,1]
quietly mean(jobschosen) if distance>3 & wid==`i'
scalar al`i'=e(b)[1,1]
replace avgnow = an`i' if wid==`i' & wid[_n]!=wid[_n-1]
replace avglater = al`i' if wid==`i' & wid[_n]!=wid[_n-1]
}
}

*Estimate within-subject correlation for main sample
corr avgnow avglater

*Generate the average difference between the two dates for each individual
gen avgdiff=avglater-avgnow

*Calculate Hedge's g_D for repeated measure manually (effect sizes for repeated measures are not supported by Stata)
sum avgdiff
scalar nu=`r(N)'-2
scalar J=exp(lngamma(0.5*nu))/(sqrt(nu*0.5)*exp(lngamma(0.5*(nu-1)))) //Note that the lngamma and not the gamma function is supported in Stata
scalar meandiff=`r(mean)'
display `r(mean)'/`r(sd)'*J

*Calculate Hedge's g_p for repeated measure manually
sum avgnow 
scalar sd1=`r(sd)'
sum avglater
scalar sd2=`r(sd)'
display meandiff/(sqrt(0.5*(sd1^2+sd2^2)))*J
*/
**The current study
//Pilot data stored separately.

*Calculate required difference and effect size for between-subject comparison (Early vs. Late)
power twomeans (242) , sd(150) alpha(0.05) power(0.8) diff(60)

esizei 100 302 150    100 242 150

*Calculate required difference and effect size for within-subject comparison (Revise, date 0 vs. date 1)
power pairedmeans (242) , sd(150) corr(0.5 0.8) alpha(0.05) n(200) power(0.8) 

scalar Cohend=`r(delta)'
scalar nu=`r(N)'-2
scalar J=exp(lngamma(0.5*nu))/(sqrt(nu*0.5)*exp(lngamma(0.5*(nu-1)))) //Note that the lngamma and not the gamma function is supported in Stata
display Cohend*J

***Figure S.1: Draw graph of power for between-comparison
power twomeans (242) , sd(150) alpha(0.05) n(100(10)400) diff(40 50 60 70) graph(y(power) title("") subtitle("") xtitle("Sample size")  scheme(lean1) schemegrid ///
plot1opts( yscale(r(0,1.15)) ylabel(0(0.2)1) recast(line) lpattern(solid) lcolor(black) lwidth(medthick))  plot2opts(recast(line) lpattern(solid) lcolor(gs9) lwidth(medthick))  plot3opts(recast(line) lpattern(solid) lcolor(navy) lwidth(medthick)) plot4opts(recast(line) lpattern(solid) lcolor(dkgreen) lwidth(medthick)) ///
legend(label(1 " {&mu}{sub:2}-{&mu}{sub:1}=40") label(2 " {&mu}{sub:2}-{&mu}{sub:1}=50") label(3 " {&mu}{sub:2}-{&mu}{sub:1}=60") label(4 "{&mu}{sub:2}-{&mu}{sub:1}=70")  order(4 3 2 1)  ring(0) pos(5)) )

graph export "$output/FigureS1.pdf", replace

***Figure S.2: Draw graph of power for within-comparison
power pairedmeans (242) , sd(150) corr(0.5 0.8) alpha(0.05) n(100(10)400) altdiff(20 30 40 50) graph(by(corr) y(power) title("") xtitle("Sample size")  scheme(lean1) schemegrid ///
plot1opts( yscale(r(0,1.15)) ylabel(0(0.2)1) recast(line) lpattern(solid) lcolor(black) lwidth(medthick))  plot2opts(recast(line) lpattern(solid) lcolor(gs9) lwidth(medthick))  plot3opts(recast(line) lpattern(solid) lcolor(navy) lwidth(medthick)) plot4opts(recast(line) lpattern(solid) lcolor(dkgreen) lwidth(medthick)) ///
legend(label(1 " {&mu}{sub:2}-{&mu}{sub:1}=20") label(2 " {&mu}{sub:2}-{&mu}{sub:1}=30") label(3 " {&mu}{sub:2}-{&mu}{sub:1}=40") label(4 "{&mu}{sub:2}-{&mu}{sub:1}=50")  order(4 3 2 1)  ring(0) pos(5)) )

graph export "$output/FigureS2.pdf", replace

********************************************************************************
********************************************************************************
***                              S.5 ATTRITION                               ***
********************************************************************************
********************************************************************************
***In text
**Two-sample test of proportions for completing date 0
prtesti 374 .7834 125 0.808

//See Table S.18 below for the remaining results, also for joint significance tests

********************************************************************************
********************************************************************************
***                              S.6 ROBUSTNESS                              ***
********************************************************************************
********************************************************************************

//See Tables S.21, S.22, and S.23 below for the contrast between Early and Late.

//See Tables S.24, S.25, and S.26 below for the contrast between Revise1 and Late.

//See Table S.6 below for using mistakes per table or time spent per table as proxies for effort.

********************************************************************************
********************************************************************************
***                        S.7 ALTERNATIVE MECHANISMS                        ***
********************************************************************************
********************************************************************************
***Uncertainty and Time Shocks
//See Table S.10 below.

***Learning and Overoptimism
*Effect of controlling for productivity change regarding difference between goal 0 and goal 1
eststo goal2no: reg goalrevision_cont
eststo goal2prod: reg goalrevision_cont productivity_change
suest goal2no goal2prod
test [goal2no_mean]_cons=[goal2prod_mean]_cons

**Change in enjoyment
*Descriptive statistics for enjoyment, pre-survey and post-survey
sum enjoypre enjoypost if d2completed==1

*t-test and Wilcoxon signed-rank test for change in enjoyment
ttest enjoypre=enjoypost if d2completed==1
signrank enjoypre=enjoypost if d2completed==1

//See Tables S.11 and S.12 below.

***Alternative Reference Points
//See Figures S.3, S.4, and S.5 below.

//See Table S.13 below.

***Private Goal Setting at Date 0 in Late
*Descriptive statistics on private goal setting in Late
tab goal0inmind if treatment==1

*Difference between private goal 0 and stated goal 1
gen diffgoal1=goal1-altgoal0 if goal0inmind==1
sum diffgoal1

ttest diffgoal1==0

***Attrition
///See Tables S.16, S.17, S.18, and S.19 below.

***Estimate pairwise treatment differences for Date 2
logit d2completed ib(2).treatment d0productivity1 uncertainty d0time_constrained crt enjoypre risk selfcomp econbusi, robust
test _b[1.treatment]=_b[3.treatment]
test _b[1.treatment]=_b[4.treatment]
test _b[3.treatment]=_b[4.treatment]

**Combined
logit d2completed d0late d0productivity1 uncertainty d0time_constrained crt enjoypre risk selfcomp econbusi, robust


***Increasing Motivation
*Test difference in productivity change
reg productivity_change d0late if treatment==1 | treatment==4, robust

reg productivity_change d0late, robust

*Test difference in enjoyment change
reg enjoychange d0late if treatment==1 | treatment==4, robust

reg enjoychange d0late, robust

*Test difference in time used to set goal
gen responsetime = d0response_time if d1completed==1
replace responsetime=d1response_time if treatment==1 & d1completed==1

sum responsetime if treatment==4
sum responsetime if d0late==0
sum responsetime if d0late==1

reg responsetime d0late if treatment==1 | treatment==4, robust

reg responsetime d0late, robust

***Increased Goal Commitment
*Compare goal achievement, Early vs. Revise0 and Late vs. Revise1
logit achieve_bin_display treatment if (treatment==2 | treatment==3), robust
margins, dydx(*) post

logit achieve_bin_display treatment if (treatment==1 | treatment==4), robust
margins, dydx(*) post

*Number of participants in Early who privately updated their goal, ex-post survey
tab goal1inmind if treatment==2

*Regress setting a goal twice on effort in Early
reg effort goal1inmind if treatment==2, robust

*Test difference in goal commitment
sum commit0 if treatment==2
sum commit1 if treatment==1

gen commit=commit0 if treatment==2
replace commit=commit1 if treatment==1
ttest commit, by(treatment)

ttest commit0 if treatment==2 | treatment==3, by(treatment)
ttest commit1 if treatment==1 | treatment==4, by(treatment)

***Rationality of Goals

*Goal achievement in Late
tab achieve_bin_display if treatment==1

reg achieve_cont1 if treatment==1, robust

sum achieve_cont_display if treatment==1 & achieve_bin_display==0

*Goal achievement in Revise
tab goalrevision_bin

reg achieve_cont1 if treatment>=3 & goal0==goal1, robust  

reg achieve_cont1 if treatment>=3, robust  
reg achieve_cont1 if treatment>=3 & achieve_cont1<300 & achieve_cont1>-300 & goal0==goal1, robust  
reg achieve_cont1 if treatment>=3 & achieve_cont1<300 & achieve_cont1>-300, robust

********************************************************************************
********************************************************************************
***                        S.8 RECALLING VS. REVISING                        ***
********************************************************************************
********************************************************************************
*Generate variables for absolute errors in recall
gen error0=abs(goal0-recall0)
gen error1=abs(goal1-recall1)

*Revise1: Difference in recall
ttest error0=error1 if treatment==4

*Revise0: Difference in recall
ttest error0=error1 if treatment==3

********************************************************************************
********************************************************************************
***                                S.9 TABLES                                ***
********************************************************************************
********************************************************************************
***Table S.1: Coefficients on controls for the goal setting regressions
*Early vs. Late
eststo goalS01EL: reg displaygoal ib(2).treatment base_productivity crt slidermoved response_time selfcomp risk enjoypre time_constrained if (treatment==1 | treatment==2) & schedule_error==0, robust
*Revise
eststo goalS01R: reg goalrevision_cont productivity_change crt d0slidermoved d1slidermoved d0response_time d1response_time selfcomp risk enjoypre uncertainty moretime lesstime, robust

*Combine regressions in a table and export as TeX
esttab goalS01* using "$output/TableS01.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.2: Coefficients on controls for the effort regressions
*Estimate regressions (similar to code for main analysis above)
eststo effortS02EL: reg effort ib(2).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==2) & schedule_error==0, robust
eststo effortS02LR1: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==4) & schedule_error==0, robust
eststo effortS02ER0: reg effort ib(2).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==3 | treatment==2) & schedule_error==0, robust
eststo effortS02R0R1: reg effort ib(3).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==3 | treatment==4) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effortS02EL effortS02LR1 effortS02ER0 effortS02R0R1 using "$output/TableS02.tex", replace nomtitles cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Coefficients on controls for the effort regressions") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.3: Coefficients on goal 0 or goal 1 in Revise0 and Revise1
**Table S.3-1: Goal 0
*Estimate regressions for Revise0, Revise1, and both
eststo effortS031R0no: reg effort goal0 if treatment==3, robust
eststo effortS031R0prod: reg effort goal0 d1productivity1 if treatment==3, robust
eststo effortS031R0all: reg effort goal0 d1productivity1 crt d0slidermoved d0response_time selfcomp risk enjoypre d1time_constrained uncertainty if treatment==3, robust

eststo effortS031R1no: reg effort goal0 if treatment==4, robust
eststo effortS031R1prod: reg effort goal0 d1productivity1 if treatment==4, robust
eststo effortS031R1all: reg effort goal0 d1productivity1 crt d0slidermoved d0response_time selfcomp risk enjoypre d1time_constrained uncertainty if treatment==4, robust

*Combine regressions in a table and export as TeX
esttab effortS031* using "$output/TableS03-1.tex", replace nomtitles cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Effect of goal 0 in Revise treatments") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

**Table S.3-2: Goal 1
eststo effortS032R0no: reg effort goal1 if treatment==3, robust
eststo effortS032R0prod: reg effort goal1 d1productivity1 if treatment==3, robust
eststo effortS032R0all: reg effort goal1 d1productivity1 crt d0slidermoved d0response_time selfcomp risk enjoypre d1time_constrained uncertainty if treatment==3, robust

eststo effortS032R1no: reg effort goal1 if treatment==4, robust
eststo effortS032R1prod: reg effort goal1 d1productivity1 if treatment==4, robust
eststo effortS032R1all: reg effort goal1 d1productivity1 crt d0slidermoved d0response_time selfcomp risk enjoypre d1time_constrained uncertainty if treatment==4, robust

*Combine regressions in a table and export as TeX
esttab effortS032* using "$output/TableS03-2.tex", replace nomtitles cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Effect of goal 1 in Revise treatments") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

*Redo tables without robust standard errors to enable Wald test across specifications
eststo effortS031R0no: reg effort goal0 if treatment==3
eststo effortS031R0prod: reg effort goal0 d1productivity1 if treatment==3
eststo effortS031R0all: reg effort goal0 d1productivity1 crt d0slidermoved d0response_time selfcomp risk enjoypre d1time_constrained uncertainty if treatment==3

eststo effortS031R1no: reg effort goal0 if treatment==4
eststo effortS031R1prod: reg effort goal0 d1productivity1 if treatment==4
eststo effortS031R1all: reg effort goal0 d1productivity1 crt d0slidermoved d0response_time selfcomp risk enjoypre d1time_constrained uncertainty if treatment==4

**Table S.3-2: Goal 1
eststo effortS032R0no: reg effort goal1 if treatment==3
eststo effortS032R0prod: reg effort goal1 d1productivity1 if treatment==3
eststo effortS032R0all: reg effort goal1 d1productivity1 crt d0slidermoved d0response_time selfcomp risk enjoypre d1time_constrained uncertainty if treatment==3

eststo effortS032R1no: reg effort goal1 if treatment==4
eststo effortS032R1prod: reg effort goal1 d1productivity1 if treatment==4
eststo effortS032R1all: reg effort goal1 d1productivity1 crt d0slidermoved d0response_time selfcomp risk enjoypre d1time_constrained uncertainty if treatment==4

suest effortS031R0no effortS032R0no
test [effortS031R0no_mean]goal0=[effortS032R0no_mean]goal1

suest effortS031R0prod effortS032R0prod
test [effortS031R0prod_mean]goal0=[effortS032R0prod_mean]goal1

suest effortS031R0all effortS032R0all
test [effortS031R0all_mean]goal0=[effortS032R0all_mean]goal1

suest effortS031R1no effortS032R1no
test [effortS031R1no_mean]goal0=[effortS032R1no_mean]goal1

suest effortS031R1prod effortS032R1prod
test [effortS031R1prod_mean]goal0=[effortS032R1prod_mean]goal1

suest effortS031R1all effortS032R1all
test [effortS031R1all_mean]goal0=[effortS032R1all_mean]goal1

suest effortS032R0no effortS032R1no
test [effortS032R0no_mean]goal1=[effortS032R1no_mean]goal1

suest effortS032R0prod effortS032R1prod
test [effortS032R0prod_mean]goal1=[effortS032R1prod_mean]goal1

suest effortS032R0all effortS032R1all
test [effortS032R0all_mean]goal1=[effortS032R1all_mean]goal1

***Table S.4: Goal setting, excluding outliers
*H1.2: No controls
eststo goalS04no: reg goalrevision_cont if goal0<900 & goal1<900 & goalrevision_cont>-700, robust
*H1.2: Control for baseline productivity
eststo goalS04prod: reg goalrevision_cont productivity_change if goal0<900 & goal1<900 & goalrevision_cont>-700, robust
*H1.2: All controls
eststo goalS04all: reg goalrevision_cont productivity_change crt d0slidermoved d1slidermoved d0response_time d1response_time selfcomp risk enjoypre uncertainty moretime lesstime if goal0<900 & goal1<900 & goalrevision_cont>-700, robust

*Combine regressions in a table and export as TeX
esttab goalS04* using "$output/TableS04.tex", replace nomtitles cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Goal setting, excluding outliers") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.5: 
matrix TableS05 = J(8,3,.)
matrix rownames TableS05 = "Early vs Late" " " "Late vs Revise1" " " "Early vs Revise0" " " "Revise0 vs Revise1" " "
matrix colnames TableS05 = "No controls" "Productivity" "All controls"

*Estimate regressions with different sets of controls
quietly{
*No controls
reg effort ib(2).treatment if (goal0<900 | goal0==.) & (goal1<900 | goal1==.) & effort<900, robust //Using Early as baseline
matrix TableS05[5,1] = _b[3.treatment]
matrix TableS05[6,1] = _se[3.treatment]

reg effort ib(1).treatment if (goal0<900 | goal0==.) & (goal1<900 | goal1==.) & effort<900, robust //Using Late as baseline
matrix TableS05[3,1] = _b[4.treatment]
matrix TableS05[4,1] = _se[4.treatment]

reg effort ib(3).treatment if (goal0<900 | goal0==.) & (goal1<900 | goal1==.) & effort<900, robust //Using Revise0 as baseline
matrix TableS05[7,1] = _b[4.treatment]
matrix TableS05[8,1] = _se[4.treatment]

*Control for baseline productivity
reg effort ib(2).treatment d1productivity1 if (goal0<900 | goal0==.) & (goal1<900 | goal1==.) & effort<900 & (treatment==2 | treatment==3), robust //Using Early as baseline
matrix TableS05[5,2] = _b[3.treatment]
matrix TableS05[6,2] = _se[3.treatment]

reg effort ib(1).treatment d1productivity1 if (goal0<900 | goal0==.) & (goal1<900 | goal1==.) & effort<900 & (treatment==1 | treatment==4), robust //Using Late as baseline
matrix TableS05[3,2] = _b[4.treatment]
matrix TableS05[4,2] = _se[4.treatment]

reg effort ib(3).treatment d1productivity1 if (goal0<900 | goal0==.) & (goal1<900 | goal1==.) & effort<900 & (treatment==3 | treatment==4), robust //Using Revise0 as baseline
matrix TableS05[7,2] = _b[4.treatment]
matrix TableS05[8,2] = _se[4.treatment]

*All controls
reg effort ib(2).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (goal0<900 | goal0==.) & (goal1<900 | goal1==.) & effort<900 & schedule_error==0 & (treatment==2 | treatment==3), robust //Using Early as baseline
matrix TableS05[5,3] = _b[3.treatment]
matrix TableS05[6,3] = _se[3.treatment]

reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (goal0<900 | goal0==.) & (goal1<900 | goal1==.) & effort<900 & schedule_error==0 & (treatment==1 | treatment==4), robust //Using Late as baseline
matrix TableS05[3,3] = _b[4.treatment]
matrix TableS05[4,3] = _se[4.treatment]

reg effort ib(3).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (goal0<900 | goal0==.) & (goal1<900 | goal1==.) & effort<900 & schedule_error==0 & (treatment==3 | treatment==4), robust //Using Revise0 as baseline
matrix TableS05[7,3] = _b[4.treatment]
matrix TableS05[8,3] = _se[4.treatment]
}

*Export matrix as TeX, specifying number of decimals
esttab matrix(TableS05,fmt(2 2 2 2 2 2)) using "$output/TableS05.tex" , tex  replace

***Table S.6: Comparison of average number of mistakes per table and average seconds per table between Revise1 and Late
*Estimate regressions with different sets of controls
eststo effortS06no: reg mistakes_mean ib(1).treatment if (treatment==1 | treatment==4), robust 
eststo effortS06prod: reg mistakes_mean ib(1).treatment d1productivity1 if (treatment==1 | treatment==4), robust 
eststo effortS06all: reg mistakes_mean ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==4) & schedule_error==0, robust
eststo effortS06noTIME: reg time_mean ib(1).treatment if (treatment==1 | treatment==4), robust 
eststo effortS06prodTIME: reg time_mean ib(1).treatment d1productivity1 if (treatment==1 | treatment==4), robust 
eststo effortS06allTIME: reg time_mean ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==4) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effortS06* using "$output/TableS06.tex", replace nomtitles drop(1.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Alternative outcome measures in Revise1 vs. Late") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.7: Comparison of goal 1 in Late vs. Revise0 and Revise1
eststo goalS07no: reg goal1 d0late if (treatment==1 | treatment==3 | treatment==4), robust 
eststo goalS07prod: reg goal1 d0late d1productivity1 if (treatment==1 | treatment==3 | treatment==4), robust 
eststo goalS07all: reg goal1 d0late d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==3 | treatment==4) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab goalS07* using "$output/TableS07.tex", replace nomtitles cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Comparion of goal 1 in Late vs. Revise0 and Revise1") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.8: Goal achievement in Revise0 and Revise1
*Estimate regressions with different sets of controls
eststo achieveS080no: reg achieve_cont0 if treatment>=3, robust 
eststo achieveS080prod: reg achieve_cont0 d1productivity1 if treatment>=3, robust 
eststo achieveS080all: reg achieve_cont0 d1productivity1 crt selfcomp risk enjoypre d1time_constrained if schedule_error==0 & treatment>=3, robust
eststo achieveS081no: reg achieve_cont1 if treatment>=3, robust 
eststo achieveS081prod: reg achieve_cont1 d1productivity1 if treatment>=3, robust
eststo achieveS081all: reg achieve_cont1 d1productivity1 crt selfcomp risk enjoypre d1time_constrained if schedule_error==0 & treatment>=3, robust

*Combine regressions in a table and export as TeX
esttab achieveS08* using "$output/TableS08.tex", replace nomtitles cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Goal achievement in Revise0 and Revise1") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.9: Goal achievement for goal 1 in Late vs Revise0 and Revise1
*Estimate regressions with different sets of controls
eststo achieveS09no: reg achieve_cont1 d0late if treatment!=2, robust 
eststo achieveS09prod: reg achieve_cont1 d0late d1productivity1 if treatment!=2, robust 
eststo achieveS09all: reg achieve_cont1 d0late d1productivity1 crt selfcomp risk enjoypre d1time_constrained if schedule_error==0 & treatment!=2, robust

*Combine regressions in a table and export as TeX
esttab achieveS09* using "$output/TableS09.tex", replace nomtitles cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Goal achievement of goal 1 in Late vs Revise0 and Revise1") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S10: Goal revision when controlling for uncertainty and time shocks
*Estimate regressions for those with no time shock, controls for uncertainty & time shocks, and control for continuous difference in flexible time
eststo reviseS10sample: reg goalrevision_cont productivity_change uncertainty if (treatment==3|treatment==4) & time_shock==0
eststo reviseS10shock: reg goalrevision_cont productivity_change moretime lesstime uncertainty if (treatment==3|treatment==4)
eststo reviseS10diff: reg goalrevision_cont productivity_change timediff if (treatment==3|treatment==4)

*Combine regressions in a table and export as TeX
esttab reviseS10* using "$output/TableS10.tex", replace nomtitles cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Goal revision when controlling for uncertainty and time shocks") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.11: Effect of change in enjoyment on goal revision
*Estimate regressions with and without controlling for change in productivity
eststo reviseS11no: reg goalrevision_cont enjoychange, robust
eststo reviseS11prod: reg goalrevision_cont productivity_change enjoychange, robust

*Combine regressions in a table and export as TeX
esttab reviseS11* using "$output/TableS11.tex", replace cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Effect of change in enjoyment on goal revision") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.12: Goal-productivity relation for Revise0 and Revise1 
eststo goalS120no: reg goal0 if treatment==3 | treatment==4, robust
eststo goalS120prod: reg goal0 d0productivity1 if treatment==3 | treatment==4, robust

eststo goalS121no: reg goal1 if treatment==3 | treatment==4, robust
eststo goalS121prod: reg goal1 d1productivity1 if treatment==3 | treatment==4, robust

*Combine regressions in a table and export as TeX
esttab goalS120no goalS120prod goalS121no goalS121prod using "$output/TableS12.tex", replace cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Goal-productivity relation") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.13: Goal setting (time- and earnings-equivalents)
**Generate variables
*Generate time equivalents of individual goals
gen timeequiv0=goal0/(d0productivity1/3) 
gen timeequiv1=goal1/(d1productivity1/3) 

gen timeequiv=timeequiv0 if treatment==2
replace timeequiv=timeequiv1 if treatment==1

gen timerevise=timeequiv1 - timeequiv0 if treatment==3 | treatment==4

*Create earnings equivalent variables for goals and effort
gen earnequiv0=.
gen earnequiv1=.
gen earneffort=.

*Loop over goals to insert their earnings equivalent
quietly{
forvalues j=1(1)1000 {
replace earnequiv0=earningssched[397+`j'] if goal0==`j'
replace earnequiv1=earningssched[397+`j'] if goal1==`j'
replace earneffort=earningssched[397+`j'] if effort==`j'
}
replace earnequiv0=0 if goal0==0
replace earnequiv1=0 if goal1==0
replace earneffort=0 if effort==0
}

gen earnequiv=earnequiv0 if treatment==2
replace earnequiv=earnequiv1 if treatment==1

gen earnrevise=earnequiv1-earnequiv0 if treatment==3 | treatment==4

**Table S.13-1: Time-equivalent goals
eststo goalS131no: reg timeequiv ib(2).treatment if treatment==1 | treatment==2, robust
eststo goalS131all: reg timeequiv ib(2).treatment crt slidermoved response_time selfcomp risk enjoypre time_constrained if (treatment==1 | treatment==2) & schedule_error==0, robust

eststo goalS131noR: reg timerevise, robust
eststo goalS131allR: reg timerevise crt d0slidermoved d1slidermoved d0response_time d1response_time selfcomp risk enjoypre uncertainty moretime lesstime, robust

*Combine regressions in a table and export as TeX
esttab goalS131no goalS131all goalS131noR goalS131allR using "$output/TableS13-1.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Goal Setting") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

**Table S.13-2: Earnings-equivalent goals
eststo goalS132no: reg earnequiv ib(2).treatment if treatment==1 | treatment==2, robust
eststo goalS132prod: reg earnequiv ib(2).treatment base_productivity if treatment==1 | treatment==2, robust
eststo goalS132all: reg earnequiv ib(2).treatment base_productivity crt slidermoved response_time selfcomp risk enjoypre time_constrained if (treatment==1 | treatment==2) & schedule_error==0, robust

eststo goalS132noR: reg earnrevise, robust
eststo goalS132prodR: reg earnrevise productivity_change, robust
eststo goalS132allR: reg earnrevise productivity_change crt d0slidermoved d1slidermoved d0response_time d1response_time selfcomp risk enjoypre uncertainty moretime lesstime, robust

*Combine regressions in a table and export as TeX
esttab goalS132no goalS132prod goalS132all goalS132noR goalS132prodR goalS132allR using "$output/TableS13-2.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Goal Setting") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.14: Coefficients on the displayed goal in the effort regressions
eststo effortS14EL: reg effort ib(2).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==1 | treatment==2) & schedule_error==0, robust
eststo effortS14LR1: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==1 | treatment==4) & schedule_error==0, robust
eststo effortS14ER0: reg effort ib(2).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==2 | treatment==3) & schedule_error==0, robust
eststo effortS14R0R1: reg effort ib(3).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==3 | treatment==4) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effortS14* using "$output/TableS14.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Coefficients on the displayed goal") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.15: Comparison of effort in Late vs. Revise1
*Generate variable for first goal
gen firstgoal=goal1 if treatment==1
replace firstgoal=goal0 if treatment==4

eststo effortS151no: reg effort ib(1).treatment goal1 if treatment==1 | treatment==4, robust
eststo effortS151prod: reg effort ib(1).treatment goal1 d1productivity1 if treatment==1 | treatment==4, robust
eststo effortS151all: reg effort ib(1).treatment goal1 d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==4) & schedule_error==0, robust
eststo effortS15fno: reg effort ib(1).treatment firstgoal if treatment==1 | treatment==4, robust
eststo effortS15fprod: reg effort ib(1).treatment firstgoal d1productivity1 if treatment==1 | treatment==4, robust
eststo effortS15fall: reg effort ib(1).treatment firstgoal d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==4) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effortS151no effortS151prod effortS151all effortS15fno effortS15fprod effortS15fall using "$output/TableS15.tex", replace nomtitles drop(1.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Coefficients on the displayed goal") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.16: Participation at Date 0
*Prepare table
matrix TableS16 = J(3,3,.)
matrix colnames TableS16 = "Emails Sent for Date 0" "Completed Date 0" "Share Completed Date 0"
matrix rownames TableS16 = "Early, Revise0, \& Revise1" "Late" "Total"

*Number of mails sent are entered manually
scalar mails0ER = 374
scalar mails0L = 125
scalar mails0T = 499

matrix TableS16[1,1] = mails0ER
matrix TableS16[2,1] = mails0L
matrix TableS16[3,1] = mails0T

*Insert the number of subjects who completed the date-0 part
drop if d0late==0 & goal0==.
count if d0late==0
matrix TableS16[1,2] = r(N)
scalar d0ER=r(N)

count if d0late==1
matrix TableS16[2,2] = r(N)
scalar d0L=r(N)

matrix TableS16[3,2] = d0ER + d0L

*Calculate the share who completed the date-0 part
matrix TableS16[1,3] = d0ER / mails0ER * 100
matrix TableS16[2,3] = d0L / mails0L * 100
matrix TableS16[3,3] = (d0ER + d0L) / mails0T * 100

*Export matrix as TeX, specifying number of decimals
esttab matrix(TableS16,fmt(0 0 2)) using "$output/TableS16.tex", tex  replace

***Table S.17: Attrition for Dates 1 and 2
*Prepare table
matrix TableS17 = J(6,5,.)
matrix colnames TableS17 = "Emails sent for Date 1" "Completed Date 1" "Share Completed Date 1" "Completed Date 2" "Share Completed Date 2" 
matrix rownames TableS17 = "Early, Revise0, Revise1" "Late" "Early" "Revise0" "Revise1" "Total"

*Number of mails sent are entered manually
scalar mails1ER = 293
scalar mails1L = 101
scalar mails1T = mails1ER + mails1L

matrix TableS17[1,1] = mails1ER
matrix TableS17[2,1] = mails1L
matrix TableS17[6,1] = mails1T

*Insert the number of subjects who completed the date-1 part
count if (treatment==2 | treatment==3 | treatment==4)
matrix TableS17[1,2] = r(N)
scalar d1ER=r(N)

count if treatment==1
matrix TableS17[2,2] = r(N)
scalar d1L=r(N)

count if treatment==2
matrix TableS17[3,2] = r(N)
scalar d1E=r(N)

count if treatment==3
matrix TableS17[4,2] = r(N)
scalar d1R0=r(N)

count if treatment==4
matrix TableS17[5,2] = r(N)
scalar d1R1=r(N)

matrix TableS17[6,2] = d1L + d1E + d1R0 + d1R1

*Insert the number of subjects who completed the date-2 part
count if (treatment==2 | treatment==3 | treatment==4) & d2completed==1
matrix TableS17[1,4] = r(N)
scalar d2ER=r(N)

count if treatment==1 & d2completed==1
matrix TableS17[2,4] = r(N)
scalar d2L=r(N)

count if treatment==2 & d2completed==1
matrix TableS17[3,4] = r(N)
scalar d2E=r(N)

count if treatment==3 & d2completed==1
matrix TableS17[4,4] = r(N)
scalar d2R0=r(N)

count if treatment==4 & d2completed==1
matrix TableS17[5,4] = r(N)
scalar d2R1=r(N)

matrix TableS17[6,4] = d2L + d2E + d2R0 + d2R1

*Calculating and inserting the share who completed date 1 and date 2
matrix TableS17[1,3] = d1ER / mails1ER * 100
matrix TableS17[2,3] = d1L / mails1L * 100
matrix TableS17[6,3] = (d1L + d1ER)/ mails1T * 100

matrix TableS17[1,5] = (d2E + d2R0 + d2R1) / d1ER * 100
matrix TableS17[2,5] = d2L / d1L * 100
matrix TableS17[3,5] = d2E / d1E * 100
matrix TableS17[4,5] = d2R0 / d1R0 * 100
matrix TableS17[5,5] = d2R1 / d1R1 * 100
matrix TableS17[6,5] = (d2L + d2E + d2R0 + d2R1) / (d1L + d1E + d1R0 + d1R1) * 100

*Export matrix as TeX, specifying number of decimals
esttab matrix(TableS17,fmt(0 0 2 0 2)) using "$output/TableS17.tex", tex  replace

***Table S.18: Selection on observables 
*Estimate logit models for attrition at date 1 and 2
logit d1completed d0late, robust
eststo att1no: margins, dydx(*) post

logit d1completed d0late d0productivity1, robust
eststo att1prod: margins, dydx(*) post

logit d1completed d0late d0productivity1 uncertainty d0time_constrained crt enjoypre risk selfcomp econbusi, robust
eststo att1all: margins, dydx(*) post

logit d2completed ib(2).treatment, robust
eststo att2no: margins, dydx(*) post

logit d2completed ib(2).treatment d0productivity1, robust
eststo att2prod: margins, dydx(*) post

logit d2completed ib(2).treatment d0productivity1 uncertainty d0time_constrained crt enjoypre risk selfcomp econbusi, robust
eststo att2all: margins, dydx(*) post

*Combine regressions in a table and export as TeX
esttab att1no att1prod att1all att2no att2prod att2all using "$output/TableS18.tex", replace cells(b(star fmt(3)) se(par fmt(2))) drop(2.treatment) ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Selection on observables") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses." "Estimates are Average Partial Effects.")

***Table S.19: Selective attrition
*Estimate models for goal0 and productivity at date 1 and 2
eststo selatt1no: reg goal0 d1completed, robust
eststo selatt1prod: reg goal0 d1completed d0productivity1, robust
eststo selatt1all: reg goal0 d1completed d0productivity1 uncertainty d0time_constrained crt enjoypre risk selfcomp econbusi, robust

eststo selatt1noprod: reg d0productivity1 d1completed if d0late==0, robust
eststo selatt1allprod: reg d0productivity1 d1completed uncertainty d0time_constrained crt enjoypre risk selfcomp econbusi if d0late==0, robust

*Combine regressions in a table and export as TeX
esttab selatt1* using "$output/TableS19.tex", replace cells(b(star fmt(3)) se(par fmt(2))) ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Selection on observables") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses." "Estimates are Average Partial Effects.")

***Table S20: Summary statistics of control and key background variables
*Prepare matrix
matrix TableS20 = J(8,5,.)
matrix colnames TableS20 = "Early" "Late" "Revise0" "Revise1" "Total"
matrix rownames TableS20 = "CRT" "Self-Competition" "Risk Tolerance" "Pleasure in Task (Date 0)" "Time Constrained (A)" "Exams & Assignments" "Age" "Share of Econ/Business"

*Loop over variables included in the summary statistics, filling out the data for each treatment
quietly{
local countrow=1
foreach i in crt selfcomp risk enjoypre d1time_constrained examassign age econbusi {
	forvalues j = 1(1)5 {
		if `j'==1 {
			summarize `i' if treatment==1
			matrix TableS20[`countrow',2] = r(mean)
		}

		if `j'==2 {
			summarize `i' if treatment==2
			matrix TableS20[`countrow',1] = r(mean)
		}

		if `j'==3 {
			summarize `i' if treatment==3
			matrix TableS20[`countrow',3] = r(mean)
		}

		if `j'==4 {
			summarize `i' if treatment==4
			matrix TableS20[`countrow',4] = r(mean)
		}		

		if `j'==5 {
			summarize `i' if d1completed==1
			matrix TableS20[`countrow',5] = r(mean)
		}
	}
local countrow=`countrow'+1
}
}
*Exporting matrix as TeX, specifying number of decimals
esttab matrix(TableS20,fmt(2 2 2 2 2 2 2 2)) using "$output/TableS20.tex", tex  replace

***Table S.21: Comparison of goals set in Early and Late using median regression
*Estimate median regressions with different sets of controls
eststo goalS21no: qreg displaygoal ib(2).treatment if treatment==1 | treatment==2
eststo goalS21prod: qreg displaygoal ib(2).treatment base_productivity if treatment==1 | treatment==2
eststo goalS21all: qreg displaygoal ib(2).treatment base_productivity crt slidermoved response_time selfcomp risk enjoypre time_constrained if (treatment==1 | treatment==2) & schedule_error==0

*Combine regressions in a table and export as TeX
esttab goalS21* using "$output/TableS21.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_p, fmt(0 2) labels(N "Pseudo R2")) ///
title("Comparison of goals set in Early and Late using median regression") legend label varlabels(_cons Constant)

***Table S.22: Comparison of goals set in Early and Late
**Table S.22-1: Excluding subjects for whom the time schedule is not available
*Estimate regressions with restricted sample and different sets of controls
eststo goalS221no: reg displaygoal ib(2).treatment if (treatment==1 | treatment==2) & schedule_error==0, robust
eststo goalS221prod: reg displaygoal ib(2).treatment base_productivity if (treatment==1 | treatment==2) & schedule_error==0, robust
eststo goalS221all: reg displaygoal ib(2).treatment base_productivity crt slidermoved response_time selfcomp risk enjoypre time_constrained if (treatment==1 | treatment==2) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab goalS221* using "$output/TableS22-1.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Comparison of goals set in Early and Late using only those for whom time-schedule applies") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

**Table S.22-2: Including all who completed the date-1 part
*Estimate regressions with full sample and different sets of controls
eststo goalS222no: reg displaygoal ib(2).treatment if treatment==1 | treatment==2, robust
eststo goalS222prod: reg displaygoal ib(2).treatment base_productivity if treatment==1 | treatment==2, robust
eststo goalS222all: reg displaygoal ib(2).treatment base_productivity crt slidermoved response_time selfcomp risk enjoypre time_constrained if treatment==1 | treatment==2, robust

*Combine regressions in a table and export as TeX
esttab goalS222* using "$output/TableS22-2.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Comparison of goals set in Early and Late using all who completed the date-1 part") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.23: Comparison of goals set in Early and Late, using exams and assignments instead of time-constrained
*Estimate regressions with all who completed part 2 and all for whom the time-schedule applies
eststo goalS23all: reg displaygoal ib(2).treatment base_productivity crt slidermoved response_time selfcomp risk enjoypre examassign if treatment==1 | treatment==2, robust
eststo goalS23schedule: reg displaygoal ib(2).treatment base_productivity crt slidermoved response_time selfcomp risk enjoypre examassign if schedule_error==0 & treatment==1 | treatment==2, robust

*Combine regressions in a table and export as TeX
esttab goalS23* using "$output/TableS23.tex", replace nomtitles drop(2.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Comparison of goals set in Early and Late using exams and assignments instead of time-constrained") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.24: Comparison of effort between Revise1 and Late using median regression
*Estimate median regressions with different sets of controls
eststo effortS24no: qreg effort ib(1).treatment if treatment==1 | treatment==4
eststo effortS24prod: qreg effort ib(1).treatment d1productivity1 if treatment==1 | treatment==4
eststo effortS24all: qreg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==4) & schedule_error==0
eststo effortS24goal: qreg effort ib(1).treatment displaygoal if treatment==1 | treatment==4
eststo effortS24prodgoal: qreg effort ib(1).treatment d1productivity1 displaygoal if treatment==1 | treatment==4
eststo effortS24allgoal: qreg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==1 | treatment==4) & schedule_error==0

*Combine regressions in a table and export as TeX
esttab effortS24* using "$output/TableS24.tex", replace nomtitles drop(1.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_p, fmt(0 2) labels(N "Pseudo R2")) ///
title("Comparison of effort between Revise1 and Late using quantile regression") legend label varlabels(_cons Constant) 

***Table S.25: Comparison of effort between Revise1 and Late
**S.25-1: Excluding subjects for whom the time schedule is not available
*Estimate regressions with restricted sample and different sets of controls
eststo effortS251no: reg effort ib(1).treatment if (treatment==1 | treatment==4) & schedule_error==0, robust 
eststo effortS251prod: reg effort ib(1).treatment d1productivity1 if (treatment==1 | treatment==4) & schedule_error==0, robust 
eststo effortS251all: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==4) & schedule_error==0, robust
eststo effortS251goal: reg effort ib(1).treatment displaygoal if (treatment==1 | treatment==4) & schedule_error==0, robust 
eststo effortS251prodgoal: reg effort ib(1).treatment d1productivity1 displaygoal if (treatment==1 | treatment==4) & schedule_error==0, robust
eststo effortS251allgoal: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==1 | treatment==4) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effortS251* using "$output/TableS25-1.tex", replace nomtitles drop(1.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Comparison of effort between Revise1 and Late using only those for whom time-schedule applies") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

**Table S.25-2: Including all who completed the date-1 part
*Estimate regressions with full sample and different sets of controls
eststo effortS252no: reg effort ib(1).treatment if (treatment==1 | treatment==4), robust 
eststo effortS252prod: reg effort ib(1).treatment d1productivity1 if (treatment==1 | treatment==4), robust 
eststo effortS252all: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained if (treatment==1 | treatment==4), robust
eststo effortS252goal: reg effort ib(1).treatment displaygoal if (treatment==1 | treatment==4), robust 
eststo effortS252prodgoal: reg effort ib(1).treatment d1productivity1 displaygoal if (treatment==1 | treatment==4), robust
eststo effortS252allgoal: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre d1time_constrained displaygoal if (treatment==1 | treatment==4), robust

*Combine regressions in a table and export as TeX
esttab effortS252* using "$output/TableS25-2.tex", replace nomtitles drop(1.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Comparison of effort Revise1 and Late using all who completed part 2") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

***Table S.26: Comparison of effort between Revise1 and Late, using exams and assignments instead of time-constrained
*Estimate regressions with all controls and all controls + goal
eststo effortS26all: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre examassign if (treatment==1 | treatment==4) & schedule_error==0, robust
eststo effortS26allgoal: reg effort ib(1).treatment d1productivity1 crt selfcomp risk enjoypre examassign displaygoal if (treatment==1 | treatment==4) & schedule_error==0, robust

*Combine regressions in a table and export as TeX
esttab effortS26* using "$output/TableS26.tex", replace nomtitles drop(1.treatment) cells(b(star fmt(2)) se(par fmt(2)))  ///
starlevels(* 0.10 ** 0.05 *** 0.01) stats(N r2_a, fmt(0 2) labels(N "Adj. R2")) ///
title("Comparison of effort between Revise1 and Late") legend label varlabels(_cons Constant) addnotes("Robust standard errors in parentheses.")

********************************************************************************
********************************************************************************
***                               S.10 FIGURES                               ***
********************************************************************************
********************************************************************************
***Figure S.3: Goals and effort
*Create individual plots and combine into one
hist goal0 , width(1)start(0) lcolor(gs12) freq title("Goal 0 (except Late)") fcolor(gs12) xscale(range(0 1000) titlegap(1)) xtitle("Goal 0") xlabel(0(100)1000, angle(vertical) nogrid) ytitle("N") yscale(r(0,50)) ylabel(0(10)50)  scheme(lean1) saving("$temp/goal0histAll.gph",replace)
hist goal1 , width(1)start(0) lcolor(gs12) freq title("Goal 1 (except Early)") fcolor(gs12) xscale(range(0 1000) titlegap(1)) xtitle("Goal 1") xlabel(0(100)1000, angle(vertical) nogrid) ytitle("N") yscale(r(0,50)) ylabel(0(10)50)  scheme(lean1) saving("$temp/goal1histAll.gph",replace)
hist effort , width(1)start(0) lcolor(gs12) freq title("Effort") fcolor(gs12) xscale(range(0 1000) titlegap(1)) xtitle("Effort") xlabel(0(100)1000, angle(vertical) nogrid) ytitle("N") yscale(r(0,50)) ylabel(0(10)50)  scheme(lean1) saving("$temp/efforthistAll.gph",replace)

gr combine "$temp/goal0histAll.gph" "$temp/goal1histAll.gph" "$temp/efforthistAll.gph", ///
	col(2) iscale(0.7)  scheme(lean1) title("Goals and effort") 
graph export "$output/FigureS3.pdf", replace

***Figure S.4: Time equivalent of goals and actual time spent
//Note that both timequiv and earnequiv variables are generated for Table S.13 above.
*Create individual plots and combine into one
hist timeequiv0 if timeequiv0<=180, width(1)start(0) lcolor(gs12) freq title("Goal 0 (except Late)") fcolor(gs12) xscale(range(0 180) titlegap(1)) xtitle("Minutes") xlabel(0(10)180, angle(vertical) nogrid) ytitle("N") yscale(r(0,10)) ylabel(0(1)10)  scheme(lean1) saving("$temp/timeeq0histAll.gph",replace)
hist timeequiv1 if timeequiv1<=180, width(1)start(0) lcolor(gs12) freq title("Goal 1 (except Early)") fcolor(gs12) xscale(range(0 180) titlegap(1)) xtitle("Minutes") xlabel(0(10)180, angle(vertical) nogrid) ytitle("N") yscale(r(0,10)) ylabel(0(1)10)  scheme(lean1) saving("$temp/timeeq1histall.gph",replace)

gr combine "$temp/timeeq0histAll.gph" "$temp/timeeq1histAll.gph" , ///
	col(2) iscale(0.7)  scheme(lean1) title("Time equivalent of goal") 
graph export "$output/FigureS4.pdf", replace

***Figure S.5: Earnings equivalent of goals set by subjects vs actual earnings
*Create individual plots and combine into one
hist earnequiv0 if d1completed==1, width(1)start(0) lcolor(gs12) freq title("Goal 0 (except Late)") fcolor(gs12) xscale(range(0 164) titlegap(1)) xtitle("DKK") xlabel(0(10)164, angle(vertical) nogrid) ytitle("N") yscale(r(0,50)) ylabel(0(10)50)  scheme(lean1) saving("$temp/earneq0histAll.gph",replace)
hist earnequiv1 , width(1)start(0) lcolor(gs12) freq title("Goal 1 (except Early)") fcolor(gs12) xscale(range(0 164) titlegap(1)) xtitle("DKK") xlabel(0(10)164, angle(vertical) nogrid) ytitle("N") yscale(r(0,50)) ylabel(0(10)50)  scheme(lean1) saving("$temp/earneq1histAll.gph",replace)
hist earneffort, width(1)start(0) lcolor(gs12) freq title("Actual earnings") fcolor(gs12) xscale(range(0 164) titlegap(1)) xtitle("DKK") xlabel(0(10)164, angle(vertical) nogrid) ytitle("N") yscale(r(0,50)) ylabel(0(10)50)  scheme(lean1) saving("$temp/earnefforthistAll.gph",replace)

gr combine "$temp/earneq0histAll.gph" "$temp/earneq1histAll.gph" "$temp/earnefforthistAll.gph" , ///
	col(2) iscale(0.7)  scheme(lean1) title("Earnings equivalent of goal" "vs actual earnings") 
graph export "$output/FigureS5.pdf", replace